
#include <ESP8266WiFi.h>        
#include <ESP8266WiFiMulti.h>   
#include <ESP8266WebServer.h>   
 
ESP8266WiFiMulti wifiMulti;    
 
ESP8266WebServer esp8266_server(80);
                                   
void setup(void){
  Serial.begin(9600);         
  wifiMulti.addAP("wsm", "WSM19900509");  
  wifiMulti.addAP("MERCURY_394B46", "wifi19900509wifi"); 
                                              
  int i = 0;                                 
  while (wifiMulti.run() != WL_CONNECTED) {  
    delay(1000);                            
    Serial.print(i++); Serial.print(' ');    
  }                                        
  Serial.print("IP address: ");           
  Serial.println(WiFi.localIP());         
  

  esp8266_server.begin(); 
  esp8266_server.on("/", handleRoot);  
  esp8266_server.on("/hello",handleHelloESP);    
  esp8266_server.onNotFound(handleNotFound);        

  Serial.println("HTTP esp8266_server started");
}
 
void loop(void){
  esp8266_server.handleClient();    
}
                                                                      
void handleRoot() {  
  esp8266_server.send(200, "text/plain", "Hello from ESP8266");  
}

void handleHelloESP() {  
  esp8266_server.send(200, "text/plain", "Hello  World"); 
}
 
void handleNotFound(){                                       
  esp8266_server.send(404, "text/plain", "404: Not found");  
}